<html>
<body>
<script src="sh.js"></script>
<?php
require("../config.php");

if($_SESSION['login'] != "" && $_SESSION['pass'] != ""){
  $login = $_SESSION['login'];
?>
<h1><?php echo "Hello, $login!";?></h1>

<h2 style="cursor:hand" onClick="expandit(this)">Links: </h2>
<span style="display:" style=&{head};>
<!-- Links start-->
<?php
  $query = "SELECT * FROM links WHERE login = '$login'";
  $result = mysql_query($query);
  $number = mysql_numrows($result);
  $i = 0;
  if ($number == 0){
    echo "You have no links.";
  }elseif ($number > 0){
    echo "<p>Link count: $number<br><br>";
    while ($i < $number){
      $name = mysql_result($result,$i,"name");
      $link = mysql_result($result,$i,"link");
      echo "<a href=$link target=_blank>$name</a></br>\n";
      $i++;
    };
  };
?>
<p>Add new link: </p>
<form action=addlink.php method=POST>
<input type=text name=name value=Name><input type=text name=link value=Link><input type=Submit>
</form>
</span>
<!-- Links end-->

<h2 style="cursor:hand" onClick="expandit(this)">Texts </h2>
<span style="display:none" style=&{head};>
<!-- Texts start-->
<?php
  $query = "SELECT * FROM texts WHERE login = '$login'";
  $result = mysql_query($query);
  $number = mysql_numrows($result);
  $i = 0;
  if ($number == 0){
    echo "You have no texts.";
  }elseif ($number > 0){
    echo "<p>Text count: $number<br><br>";
    while ($i < $number){
      $name = mysql_result($result,$i,"name");
      $text = mysql_result($result,$i,"text");
      echo "$name </br>$text</br></br>\n";
      $i++;
    };
  };
?>
<p>Add new text: </p>
<form action=addtext.php method=POST>
<input type=text name=name value=Name></br><textarea name=text></textarea></br><input type=Submit>
</form>
</span>
<!-- Texts end-->


<h2 style="cursor:hand" onClick="expandit(this)">Your photos</h2>
<span style="display:none" style=&{head};>
<!-- Photos start-->
<?php
  $query = "SELECT * FROM photos WHERE login = '$login'";
  $result = mysql_query($query);
  $number = mysql_numrows($result);
  $i = 0;
  if ($number == 0){
    echo "You have no photos.";
  }elseif ($number > 0){
    echo "<p>Photos count: $number<br><br>";
    while ($i < $number){
      $name = mysql_result($result,$i,"name");
      $photo = mysql_result($result,$i,"photo");
      echo "$name </br><img src=$photo alt=$name></br>\n";
      $i++;
    };
  };
?>
<p>Upload photo</p>
<form action="uploadimage.php" method="POST" ENCTYPE="multipart/form-data">
 Select the file to upload: <input type="file" name="userfile">
 Photo name: <input type=text name=name>
 <input type="submit" name="upload" value="upload">
</form>
</span>
<!-- Photos end-->
<h2><a href=addtrick.php target=_blank>Add trick!</a></h2>
<?php
};
mysql_close();
?>
<hr>
<i>Created by Andrue Konstantinov</i>
</body>
</html>
